package cn.gson.fengboot.controller;

import cn.gson.fengboot.model.pojos.Lchucha;
import cn.gson.fengboot.model.service.LchuchaService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/vue")
public class LchuchaController {
    @Autowired
    LchuchaService lchuchaService;


    //查询所有客户的服务
    @RequestMapping("/cxchucha")
    @ResponseBody
    //查询出差记录
    public Map<String,Object> khkefu(Integer currentPage , Integer pageSize,String search,String fenlei){
        if(currentPage==null || currentPage==' '||pageSize==null||pageSize==' '){
            currentPage=1;
            pageSize=5;
        }
        Page<Object> obj= PageHelper. startPage(  currentPage, pageSize);
        List<Lchucha> lchuchas = lchuchaService.cxchucha(search,fenlei);
        Map<String,Object> map = new HashMap<>();
        map.put("total",obj.getTotal());
        map.put("row",lchuchas);
        return map;
    }


    //新增客户服务信息
    @RequestMapping("/addlchucha")
    @ResponseBody
    public  void addlchucha(@RequestBody Lchucha lchucha){
        System.out.println("111111111"+lchucha);
        lchuchaService.addchucha(lchucha);
    }

}
